package com.xiaoxu.intranetweb.mybatisplusSzappdb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.Gps18DeviceBindTruck;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.Gps18TruckOverspeed;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.mapper.Gps18TruckOverspeedMapper;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.IGps18TruckOverspeedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoxu.intranetweb.util.StringUtils;
import com.xiaoxu.intranetweb.util.SzResult;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lvNuo
 * @since 2025-04-03
 */
@Service
public class Gps18TruckOverspeedServiceImpl extends ServiceImpl<Gps18TruckOverspeedMapper, Gps18TruckOverspeed> implements IGps18TruckOverspeedService {

    @Override
    public SzResult getList(Integer page, Integer pageSize, String truckNo, String startTime, String endTime) {
        QueryWrapper<Gps18TruckOverspeed> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(truckNo),"TRUCK_NO",truckNo);
        queryWrapper.ge(StringUtils.isNotEmpty(startTime),"GPS_TIME",startTime);
        queryWrapper.le(StringUtils.isNotEmpty(endTime),"GPS_TIME",endTime);
        Page<Gps18TruckOverspeed> iPage = page(new Page<Gps18TruckOverspeed>(page, pageSize), queryWrapper);
        List<Gps18TruckOverspeed> list = iPage.getRecords();
        Long total = iPage.getTotal();
        Map<String, Object> map = new HashMap<>();
        map.put("total", total);
        map.put("list", list);
        return SzResult.success(map);
    }

    @Override
    public SzResult getTruckOverspeedList(String bindId) {
        QueryWrapper<Gps18TruckOverspeed> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("BIND_ID",bindId);
        return SzResult.success(list(queryWrapper));
    }
}
